package org.jeecg.modules.product.contractor.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.product.contractor.entity.TbContractorPersonnel;
import org.jeecg.modules.product.contractor.mapper.TbContractorPersonnelMapper;
import org.jeecg.modules.product.contractor.mapper.TbContractorPersonnelQualificationCertificateMapper;
import org.jeecg.modules.product.contractor.service.ITbContractorPersonnelService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: 承包商人员
 * @Author: jeecg-boot
 * @Date:   2024-07-08
 * @Version: V1.0
 */
@Service
public class TbContractorPersonnelServiceImpl extends ServiceImpl<TbContractorPersonnelMapper, TbContractorPersonnel> implements ITbContractorPersonnelService {

	@Autowired
	private TbContractorPersonnelMapper tbContractorPersonnelMapper;
	@Autowired
	private TbContractorPersonnelQualificationCertificateMapper tbContractorPersonnelQualificationCertificateMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		tbContractorPersonnelQualificationCertificateMapper.deleteByMainId(id);
		tbContractorPersonnelMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			tbContractorPersonnelQualificationCertificateMapper.deleteByMainId(id.toString());
			tbContractorPersonnelMapper.deleteById(id);
		}
	}

	@Override
	public IPage<TbContractorPersonnel> queryPageListForPersonnelAndQualificationCertificate(Page<TbContractorPersonnel> page,  String name) {
		return tbContractorPersonnelMapper.queryPageListForPersonnelAndQualificationCertificate(page, name);
	}

}
